package com.shushan.accessibility.samsung;


import com.shushan.accessibility.AccessibilityOperator;

/**
 * @ClassName: SamsungOperator
 * @Desciption: //TODO
 * @author: yichaohua
 * @date: 2018-08-01
 */
public class SamsungOperator {

    private static final String TAG = "MiuiOperator";

    private static SamsungOperator mInstance = new SamsungOperator();

    public static SamsungOperator getInstance() {
        return mInstance;
    }

    public boolean closeSavePower() {
        boolean result = AccessibilityOperator.getInstance().clickById("com.samsung.android.sm_cn:id/c_layout_battery");
        if(!result){
            return false;
        }else {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            result = AccessibilityOperator.getInstance().clickById("com.samsung.android.sm_cn:id/psm_off_btn");

        }

        return result;
    }

    public boolean openComplete() {
        boolean result = AccessibilityOperator.getInstance().clickById("com.samsung.android.sm_cn:id/c_layout_applock");
        if(!result){
            return false;
        }else {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            result = AccessibilityOperator.getInstance().clickById("com.samsung.android.sm_cn:id/c_autorun_button");
            if(!result){
                return false;
            }else {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

                return AccessibilityOperator.getInstance().clickListItemSwitch("android:id/list","书山宝",1,true);
            }

        }

    }

    public boolean openFloatManager() {
        return AccessibilityOperator.getInstance().clickOnlySwitch(true);
    }

    public boolean openUsageSetting() {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        boolean result = AccessibilityOperator.getInstance().clickListItem("android:id/list","书山宝",1);
        if(!result){
            return false;
        }else {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            return AccessibilityOperator.getInstance().clickOnlySwitch(true);
        }

    }

    public boolean enableAdmin() {
        return AccessibilityOperator.getInstance().clickById("com.android.settings:id/action_button");
    }
}
